package com.smedi.ismedi.notification.core.port.adapter.persistence.repository.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smedi.ismedi.notification.core.domain.aggregatemodel.SmsLog;
import com.smedi.ismedi.notification.core.domain.repository.SmsLogRepository;
import com.smedi.ismedi.notification.core.port.adapter.persistence.model.SmsLogEntity;
import com.smedi.ismedi.notification.core.port.adapter.persistence.mybatis.mapper.SmsLogMapper;
import com.smedi.ismedi.web.starter.util.DozerUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

@Slf4j
@Repository
@AllArgsConstructor
public class SmsLogRepositoryImpl extends ServiceImpl<SmsLogMapper, SmsLogEntity> implements SmsLogRepository, IService<SmsLogEntity> {
    private final DozerUtil dozerUtil;

    @Override
    public SmsLog doInsert(SmsLog data) {
        SmsLogEntity smsLogEntity = dozerUtil.convertor(data, SmsLogEntity.class);
        this.getBaseMapper().insert(smsLogEntity);
        return dozerUtil.convertor(smsLogEntity, SmsLog.class);
    }
}